package com.ruoyi.rulengine.handler;

import com.ruoyi.rulengine.domain.RuleAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class RuleActionFactory {

    @Autowired
    private  Map<String, RuleActionHandler> handlers = new HashMap<>();


    public  RuleActionHandler getHandler(RuleAction ruleAction) {
        RuleActionHandler handler =  handlers.get(ruleAction.getType());
        if (handler != null) {
            // 执行动作
            return handler;
        } else {
            throw new IllegalArgumentException("不支持的动作类型：" + ruleAction.getType());
        }
    }
}
